<template>
   <el-table
   size="mini"
    ref="multipleTable"
    :data="arr"
    style="width: 100%"
    @selection-change="handleSelectionChange">
     <el-table-column
     align="center"
      type="selection"
      width="55">
    </el-table-column>
    <el-table-column
    align="center"
      prop="username"
      sortable
      label="医生姓名"
      width="150">
    </el-table-column>
     <el-table-column
      prop="Amsg"
      align="center"
      label="医生头像"
      width="100"
      
      >
       <el-image
      style="width: 40px; height: 30px"
      :src="url"
     ></el-image>
    </el-table-column>
    <el-table-column
    align="center"
      prop="area"
      label="地区"
      width="100">
    </el-table-column>
    <el-table-column
    align="center"
      prop="zc"
      label="职称"
      width="100">
    </el-table-column>
    <el-table-column
    align="center"
      prop="keshi"
      label="科室"
      width="180"
    >
    </el-table-column>
   
    <el-table-column 
    align="center"
    prop="date"
    label="标签"
    width="200">
     <el-tag size="small" type="success">糖尿病</el-tag>
     <el-tag size="small" type="warning">尿毒病</el-tag>
     <el-tag size="small">肾病</el-tag>
    </el-table-column>
     <el-table-column
     align="center"
      prop="address"
      label="医生简介"
      width="300"
      >
    </el-table-column>
     <el-table-column
      align="center"
      fixed="right"
      prop="czuo"
      label="操作"
      width="">
      <template slot-scope="scope" >
        <el-button 
        @click="handleClick(scope.row)" 
        type="text" size="small" 
        class="el-icon-edit-outline"
        style="font-size:18px"></el-button>
        <el-button 
        type="text" 
        size="small" 
        class="el-icon-delete"
        style="font-size:18px"
        @click="delFn(scope.row.id)">
        </el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import {deleById} from '../../../api/home1.js'
import {delAllFn} from '../../../api/home1.js'
import eventBus from '../../../utils/busEvent'
export default {
  props:['arr'],
    data(){
      return {
        url: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
        multipleSelection:[],
      }
    },
    mounted(){
       eventBus.$on('delalltarnder',this.deleAllFn)
    },
    methods:{
        handleClick(row){
          this.$emit('bianjiFn',row)
        },
        handleSelectionChange(val) {
          console.log(val);
        this.multipleSelection = val;
      },
      //全部删除
      deleAllFn(){
       var ids=""
       this.multipleSelection.forEach(item=>{
         ids+=item.id +','
       })
       console.log(ids,'ids');
       delAllFn({ids:ids}).then(res=>{
         console.log(res);
         if(res.code ==200){
           this.$emit('delAllFntran')
         }
       })
      },
      //删除
      delFn(id){
        // console.log(id);
        deleById({id:id}).then(res=>{
          if(res.code==200){
            this.$emit('deltranfer',id)
          }
        })
       
      }
    }
  }
</script>

<style >
 .el-table__cell{
  line-height: 30px;
}
.el-tag {
  margin-right: 5px;
 
}
.has-gutter{
line-height: 18px;
}
.el-tag--light{
   border-radius: 24px;
}
.el-icon-edit-outline{
  font-size: 24px;
}
</style>